const path = require('path');
const express = require('express');
const morgan = require('morgan');
const nunjucks = require('nunjucks');

const studentRouter = require( './routes/student.js' );

const port = 8080 ;
const app = express();

const dir = 'views' ;

app.set( 'view engine' , 'njk' );
app.set( 'views' , path.resolve( __dirname , dir ) );

nunjucks.configure( dir , { autoescape:true, express:app , noCache: true } );

app.use( morgan('dev') );
app.use( express.json() );
app.use( express.urlencoded({ extended: false }) );
app.use( express.static('public') );

app.use( studentRouter );

app.listen( port );
